import { DataSource } from "typeorm";
const { NODE_ENV } = process.env;
export const dataSource = new DataSource({
  type: "mysql",
  host: "localhost",
  port: 3306,
  username: "root",
  password: "root",
  database: "sq_travelworld",
  timezone: "Z",
  entities: [__dirname + "/model/*{.ts,.js}"],
  //同步实体类结构到数据库
  synchronize: false,//NODE_ENV !== 'pod'
  // 打印sql
  logging: NODE_ENV !== 'prod',
});

dataSource
  .initialize()
  .then(() => {
    // dataSource.entityMetadatas：获取所有实体的元数据
  })
  .catch((error) => console.log(error))